package com.tz.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * Created by heziqian on 2016/10/21.
 */
@Entity
@Table(name = "ONLINE_ADDRESS")
public class Address implements Serializable{

        /**
         *地址属性
         */
        private static final long serialVersionUID = -2078682106682209338L;
        private Long addressId;//地址id
        private String area;//区域
        private String detailAdders;//详细地址
        private String emailCode;//电子邮箱
        private String receiver;//接受者
        private String tel;//电话
        private String isDefault;//默认值
        private User user;//用户
        public Address() {
            super();
        }

        public Address(String area, String detailAdders, String emailCode,
                       String receiver, String tel, String isDefault, User user) {
            super();
            this.area = area;
            this.detailAdders = detailAdders;
            this.emailCode = emailCode;
            this.receiver = receiver;
            this.tel = tel;
            this.isDefault = isDefault;
            this.user = user;
        }

        @Id
        @GeneratedValue(strategy = GenerationType.AUTO, generator = "address_id")
        @SequenceGenerator(name = "address_id", sequenceName = "online_address_id")
        public Long getAddressId() {
            return addressId;
        }

        public void setAddressId(Long addressId) {
            this.addressId = addressId;
        }

        @Column
        public String getArea() {
            return area;
        }

        public void setArea(String area) {
            this.area = area;
        }

        @Column
        public String getDetailAdders() {
            return detailAdders;
        }

        public void setDetailAdders(String detailAdders) {
            this.detailAdders = detailAdders;
        }

        @Column
        public String getEmailCode() {
            return emailCode;
        }

        public void setEmailCode(String emailCode) {
            this.emailCode = emailCode;
        }

        @Column
        public String getReceiver() {
            return receiver;
        }

        public void setReceiver(String receiver) {
            this.receiver = receiver;
        }

        @Column
        public String getTel() {
            return tel;
        }

        public void setTel(String tel) {
            this.tel = tel;
        }

        @Column
        public String getIsDefault() {
            return isDefault;
        }

        public void setIsDefault(String isDefault) {
            this.isDefault = isDefault;
        }

        @ManyToOne
        @JoinColumn(name="user_id")
        public User getUser() {
            return user;
        }

        public void setUser(User user) {
            this.user = user;
        }

        @Override
        public String toString() {
            return "Address [addressId=" + addressId + ", area=" + area
                    + ", detailAdders=" + detailAdders + ", emailCode=" + emailCode
                    + ", receiver=" + receiver + ", tel=" + tel + ", isDefault="
                    + isDefault + "]";
        }



    }



